
package com.comtop.increment.toolbar.actions;

import java.net.URL;

import org.eclipse.jface.action.IAction;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.IWorkbenchWindowActionDelegate;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.browser.IWebBrowser;
import org.eclipse.ui.browser.IWorkbenchBrowserSupport;

import com.comtop.increment.IncrementPlugin;
import com.comtop.increment.PreferenceConstants;

public class OpenWebBrowserAction implements IWorkbenchWindowActionDelegate {
    
    public OpenWebBrowserAction() {
    }
    
    public void dispose() {
    }
    
    public void init(IWorkbenchWindow iworkbenchwindow) {
    }
    
    public void run(IAction iaction) {
        try {
            IWorkbenchBrowserSupport iworkbenchbrowsersupport = PlatformUI.getWorkbench().getBrowserSupport();
            IWebBrowser iwebbrowser = iworkbenchbrowsersupport.createBrowser(IncrementPlugin.PLUGIN_ID);
            URL url = new URL(IncrementPlugin.getDefault().getPreferencePageValue(PreferenceConstants.P_URL));
            iwebbrowser.openURL(url);
        } catch (Exception exception) {
            IncrementPlugin.log(exception);
        }
    }
    
    public void selectionChanged(IAction iaction, ISelection iselection) {
    }
    
    public void delete() {
    }
}
